package com.huawei.hms.support.api.iap.json;

import android.text.TextUtils;
import com.huawei.hms.common.internal.ResponseErrorCode;
import com.huawei.hms.common.internal.TaskApiCall;
import com.huawei.hms.support.api.client.Status;
import com.huawei.hms.support.api.entity.iap.SkuDetailResp;
import com.huawei.hms.support.api.iap.SkuDetailResult;
import com.huawei.hms.support.hianalytics.HiAnalyticsClient;
import com.huawei.hms.support.log.HMSLog;
import com.huawei.hms.utils.JsonUtil;
import o.fjx;

public class SkuDetailTaskApiCall extends TaskApiCall<IapHmsClient, SkuDetailResult> {
    public SkuDetailTaskApiCall(String str, String str2, String str3) {
        super(str, str2, str3);
    }

    protected void doExecute(IapHmsClient iapHmsClient, ResponseErrorCode responseErrorCode, String str, fjx<SkuDetailResult> o_fjx_com_huawei_hms_support_api_iap_SkuDetailResult) {
        if (responseErrorCode == null) {
            o_fjx_com_huawei_hms_support_api_iap_SkuDetailResult.ॱ(new IapApiException(new Status(1)));
            return;
        }
        HiAnalyticsClient.reportExit(iapHmsClient.getContext(), getUri(), getTransactionId(), responseErrorCode.getStatusCode(), responseErrorCode.getErrorCode());
        if (TextUtils.isEmpty(str)) {
            o_fjx_com_huawei_hms_support_api_iap_SkuDetailResult.ॱ(new IapApiException(new Status(responseErrorCode.getErrorCode(), responseErrorCode.getErrorReason())));
        } else if (responseErrorCode.getErrorCode() == 0) {
            HMSLog.i("SkuDetailTaskApiCall", "onResult, success");
            SkuDetailResp skuDetailResp = new SkuDetailResp();
            JsonUtil.jsonToEntity(str, skuDetailResp);
            SkuDetailResult skuDetailResult = new SkuDetailResult();
            skuDetailResult.setReturnCode(skuDetailResp.getReturnCode());
            skuDetailResult.setErrMsg(skuDetailResp.getErrMsg());
            skuDetailResult.setSkuList(skuDetailResp.getSkuList());
            skuDetailResult.setStatus(new Status(responseErrorCode.getStatusCode(), responseErrorCode.getErrorReason()));
            o_fjx_com_huawei_hms_support_api_iap_SkuDetailResult.ॱ(skuDetailResult);
        } else {
            HMSLog.i("SkuDetailTaskApiCall", "onResult, returnCode: " + responseErrorCode.getErrorCode());
            o_fjx_com_huawei_hms_support_api_iap_SkuDetailResult.ॱ(new IapApiException(new Status(responseErrorCode.getErrorCode(), responseErrorCode.getErrorReason())));
        }
    }
}
